package com.oa.lms.apps.business.absence.impl;

import java.util.List;

import com.oa.lms.apps.business.absence.IProcessesService;
import com.oa.lms.apps.business.user.IPostInfoService;
import com.oa.lms.apps.constants.IDEDStatus;
import com.oa.lms.apps.dao.absence.IProcessesDao;
import com.oa.lms.apps.entity.absence.ProcessesValue;

public class ProcessesServiceImpl implements IProcessesService {

	
	private IProcessesDao processesDao;
	
	private IPostInfoService postInfoService;
	
	private ProcessesValue processesValue;
	@Override
	public Integer add(String processOrder, Integer postId) {
		processesValue.setProcessOrder(processOrder);
		processesValue.setPostInfo(postInfoService.queryByPostId(postId));
		processesValue.setStatus(IDEDStatus.ENABLE);
		return processesDao.add(processesValue);
	}

	@Override
	public void modify(Integer processId, String processOrder, Integer postId) {
		processesValue = this.queryByProcessId(processId);
		processesValue.setProcessOrder(processOrder);
		processesValue.setPostInfo(postInfoService.queryByPostId(postId));
		processesDao.modify(processesValue);

	}

	@Override
	public ProcessesValue queryByProcessId(Integer processId) {
		return processesDao.queryByProcessId(processId);
	}


	@Override
	public List<ProcessesValue> queryProcesses(Integer postId, Integer status) {

		if(postId != null)
			processesValue.setPostInfo(postInfoService.queryByPostId(postId));
		if(status != null)
			processesValue.setStatus(status);
		return processesDao.queryProcesses(processesValue);
	}
	
	//Getter and Setter

	public IProcessesDao getProcessesDao() {
		return processesDao;
	}

	public void setProcessesDao(IProcessesDao processesDao) {
		this.processesDao = processesDao;
	}

	public IPostInfoService getPostInfoService() {
		return postInfoService;
	}

	public void setPostInfoService(IPostInfoService postInfoService) {
		this.postInfoService = postInfoService;
	}

	public ProcessesValue getProcessesValue() {
		return processesValue;
	}

	public void setProcessesValue(ProcessesValue processesValue) {
		this.processesValue = processesValue;
	}
	

	
	

}
